package com.lanchetech.user.controller;

import com.lanchetech.bean.request.GoodSpuListReq;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.GoodSpuListResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.SkuPriceVO;
import com.lanchetech.entity.Merchant;
import com.lanchetech.entity.ShoppingCart;
import com.lanchetech.entity.Sku;
import com.lanchetech.entity.User;
import com.lanchetech.user.config.ReturnPayInfoVO;
import com.lanchetech.user.service.GlobalGoodSpuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Api(value = "全球好物API", tags = "全球好物API")
@RequestMapping("/api/goodSpu")
@RestController
public class GlobalGoodSpuController {

    @Autowired
    private GlobalGoodSpuService globalGoodSpuService;

    @ApiOperation("全球好物一级分类商品列表")
    @GetMapping("/GoodSpuList")
    public ResultData<GoodSpuListResp> GoodSpuList(GoodSpuListReq goodSpuListReq){
        return globalGoodSpuService.GoodSpuList(goodSpuListReq);
    }

    @ApiOperation("申请代理")
    @PostMapping("/addAgency")
    public BaseResp addAgency(@RequestParam("agency") User user){
        return globalGoodSpuService.addAgency(user);
    }

    @ApiOperation("不同身份价格不同，达人价格，代理价格，厂家价格")
    @GetMapping("/getPrice")
    public ResultData<SkuPriceVO> getPrice(@RequestBody User user){
       return globalGoodSpuService.getPrice(user);
    }

    @ApiOperation("获取全部商家")
    @GetMapping("/getMerchant")
    public ResultData<List<Merchant>> getMerchant(@RequestParam long id){
        return  globalGoodSpuService.getMerchant(id);
    }

    @ApiOperation("订货广场获取商品价格详情")
    @GetMapping("/getOrderSquare")
    public ResultData<Sku> getOrderSquare(@AuthenticationPrincipal User user,@RequestParam("id") Long id){
        return globalGoodSpuService.getOrderSquare(user,id);
    }

    @ApiOperation("选品广场获取商品详情")
    @GetMapping("/getSelectionSquare")
    public ResultData<Sku> getSelectionSquare(@AuthenticationPrincipal User user,@RequestParam("id") Long id){
        return globalGoodSpuService.getSelectionSquare(user,id);
    }

    @ApiOperation("添加到购物车商品不能少于10件")
    @PostMapping("/addToShoppingCart")
    public BaseResp addToShoppingCart(@AuthenticationPrincipal User user, @RequestBody ShoppingCart shoppingCart) {
        return globalGoodSpuService.addToShoppingCart(user, shoppingCart);
    }

    @ApiOperation("代理入驻金")
    @GetMapping("/createAgencyDeposit")
    public ResultData<ReturnPayInfoVO> createAgencyDeposit(@AuthenticationPrincipal User user, @RequestParam("type") Byte type, @RequestParam("userAddressId") Long userAddressId, HttpServletRequest httpServletRequest) {
        return globalGoodSpuService.createAgencyDeposit(user, type, userAddressId, httpServletRequest);
    }



}























